package com.ssm.service;

import com.ssm.dao.CustomerDao;
import com.ssm.entity.Customer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

@Service
public class CustomerService {
    @Autowired
    private CustomerDao customerDao;

    public Customer findCustomerById(int c_id) {
        return customerDao.findCustomerById(c_id);
    }

    @Transactional
    public List<Customer> updateCustomerById(){
        List list = new ArrayList();
        Customer c;
        c = customerDao.findCustomerById(7);
        list.add(c);
        c.setC_name("希夷老道给");
        customerDao.updateCustomerById(c);
        c=customerDao.findCustomerById(8);
        System.out.println("ccgggg444555");
        list.add(c);
        int i = 5/0;
        c.setC_name("王剑人ren");
        customerDao.updateCustomerById(c);
        return list;
    }
    public Customer findByName(String name){return customerDao.findByName(name);}
    public int insertCustomer(Customer c){
        return customerDao.insertCustomer(c);
    }
}
